package net.zjitc.controller;

import net.zjitc.pojo.Category;
import net.zjitc.pojo.Product;
import net.zjitc.service.CategoryService;
import net.zjitc.service.ProductService;
import net.zjitc.service.impl.CategoryServiceImpl;
import net.zjitc.service.impl.ProductServiceImpl;
import net.zjitc.utils.PageBean;
import net.zjitc.utils.dispacher.URLMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2017/12/4.
 */
public class IndexController {
    CategoryService categoryService=new CategoryServiceImpl();
    ProductService productService=new ProductServiceImpl();
    @URLMapping(url = "/index")
    public String index(HttpServletRequest request, HttpServletResponse response){
        //准备数据 1.一级分类 2.热销商品 3.最新商品
        List<Category> clist = categoryService.findAll();
        request.setAttribute("clist",clist);

        //热销
        List<Product> plist=productService.findIsHot();
        request.setAttribute("plist",plist);

        //最新
        List<Product> pclist=productService.findNew();
        request.setAttribute("pclist",pclist);
        return "WEB-INF/user/index.jsp";
    }
}
